﻿namespace Digitalmes.Domain.Mes;

/// <summary>
/// SN 过站信息。
/// </summary>
/// <remarks>
/// 记录产品过站信息。
/// </remarks>
[SugarTable("prod_archive", "SN过站信息表")]
public class ProdArchive : EntityBaseId
{
    /// <summary>
    /// 产线 Id。
    /// </summary>
    public long LineId { get; set; }

    /// <summary>
    /// 产线编号
    /// </summary>
    [NotNull, StringLength(32)]
    public string? LineCode { get; set; }

    /// <summary>
    /// 工位 Id。
    /// </summary>
    public long OpId { get; set; }

    /// <summary>
    /// 工位编号
    /// </summary>
    [NotNull, StringLength(32)]
    public string? OpCode { get; set; }

    /// <summary>
    /// 工序 Id。没有则为0。
    /// </summary>
    public long ProcId { get; set; }

    /// <summary>
    /// 工序编号。没有则为空。
    /// </summary>
    [NotNull, StringLength(32)]
    public string? ProcCode { get; set; }

    /// <summary>
    /// SN
    /// </summary>
    [NotNull, StringLength(64)]
    public string? Sn { get; set; }

    /// <summary>
    /// 产品编号
    /// </summary>
    [StringLength(64)]
    public string? ProductCode { get; set; }

    /// <summary>
    /// 工单号，没有则为空。
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "工单号", Length = 32)]
    public string? Wo { get; set; }

    /// <summary>
    /// 过站结果
    /// </summary>
    [SugarColumn(ColumnDescription = "过站结果")]
    public PassResultEnum PassResult { get; set; }

    /// <summary>
    /// 配方号
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "配方号")]
    public string? FormualNo { get; set; }

    /// <summary>
    /// 操作人员
    /// </summary>
    [SugarColumn(ColumnDescription = "操作人员", Length = 64)]
    public string? Operator { get; set; }

    /// <summary>
    /// 班次
    /// </summary>
    [SugarColumn(ColumnDescription = "班次", Length = 16)]
    public string? Shift { get; set; }

    /// <summary>
    /// RFID 编号
    /// </summary>
    [SugarColumn(ColumnDescription = "RFID 编号", Length = 64)]
    public string? Rfid { get; set; }

    /// <summary>
    /// 用时(秒)
    /// </summary>
    [SugarColumn(ColumnDescription = "用时(秒)", Length = 8, DecimalDigits = 1)]
    public double CycleTime { get; set; }

    /// <summary>
    /// 出站/存档时间
    /// </summary>
    [SugarColumn(ColumnDescription = "出站时间")]
    public DateTime ArchiveTime { get; set; }

    /// <summary>
    /// 数据版本。
    /// </summary>
    /// <remarks>与 <see cref="ProdInbound.Version"/> 对应，反复过站时与进站关联。</remarks>
    [SugarColumn(ColumnDescription = "数据版本")]
    public long Version { get; set; }
}
